package test.test1.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import test.test1.VelocityKey;
import test.test1.mybatis.pojo.Player;
import test.test1.mybatis.pojo.Question;
import test.test1.mybatis.service.PlayerService;
import test.test1.mybatis.service.QuestionService;

@Controller
@RequestMapping("/question")
public class QuestionController {
	@Resource
	private QuestionService questionService;

	public QuestionController() {
		// TODO Auto-generated constructor stub
	}
	
	@RequestMapping("listOpen")
	public String listOpen(HttpServletRequest request, ModelMap modelMap) {
		List<Question> qs = questionService.listOpen();
		modelMap.put(VelocityKey.THELIST, qs);
		return "list";
	}
	
	@RequestMapping("listAll")
	public String listAll(HttpServletRequest request, ModelMap modelMap) {
		List<Question> qs = questionService.listAll();
		modelMap.put(VelocityKey.THELIST, qs);
		return "list";
	}
	
	@RequestMapping("search")
	public String search(HttpServletRequest request, ModelMap modelMap) {
		String key = request.getParameter("key");
		List<Question> qs = questionService.search(key);
		modelMap.put(VelocityKey.THELIST, qs);
		return "list";
	}

}
